/**
 * MIT License
 *
 * Copyright (c) 2024 小村程序员
 * Email: 397237738@qq.com
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package org.open.cobertura.core.instrument;

import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.MethodNode;

public abstract class CoberturaMethodProbeVisitor extends MethodVisitor {


    protected CoberturaMethodProbeVisitor(int api) {
        super(api);
    }
    public CoberturaMethodProbeVisitor(final MethodVisitor mv) {
        super(Opcodes.ASM9, mv);
    }
    public void accept(final MethodNode methodNode,final MethodVisitor methodVisitor) {
        methodNode.accept(methodVisitor);
    }

    public abstract void insertJumpProbe(final int opcode, int index, final Label label, IFrame frame);
    public abstract void insertProbe(final int opcode,final int index);

    /**
     * 这个方法是在label中使用的，因为不带操作码
     * @param index
     */
    public abstract void insertProbe(final int index);

    /*************************和零比较的指令**************************************/
    int IFNE() {
        return Opcodes.IFNE;
    }
    int IFEQ() {
        return Opcodes.IFEQ;
    }
    int IFGE() {
        return Opcodes.IFGE;
    }
    int IFLT() {
        return Opcodes.IFLT;
    }
    int IFLE() {
        return Opcodes.IFLE;
    }
    int IFGT() {
        return Opcodes.IFGT;
    }
    /********************************END*************************************/
    int IF_ICMPNE() {
        return Opcodes.IF_ICMPNE;
    }
    int IF_ICMPEQ() {
        return Opcodes.IF_ICMPEQ;
    }
    int IF_ICMPGE() {
        return Opcodes.IF_ICMPGE;
    }
    int IF_ICMPLT() {
        return Opcodes.IF_ICMPLT;
    }
    int IF_ICMPLE() {
        return Opcodes.IF_ICMPLE;
    }
    int IF_ICMPGT() {
        return Opcodes.IF_ICMPGT;
    }
    int IF_ACMPNE() {
        return Opcodes.IF_ACMPNE;
    }
    int IF_ACMPEQ() {
        return Opcodes.IF_ACMPEQ;
    }
    int IFNONNULL() {
        return Opcodes.IFNONNULL;
    }
    int IFNULL() {
            return Opcodes.IFNULL;
    }
}
